Primitive Value:  Undefined


Undefined
 
In ECMAScript, Undefined is classified as a primitive value. Your ability to use Undefined will be extremely dependent upon the type and version of your browser.
 
There are two definitions for Undefined. It can refer to a variable that has never been declared. Or it can refer to a variable that has been declared, but has not been assigned a value. The ECMA-262 standard uses the second version to define Undefined.
 
Undefined is also a type. You can use the typeof operator to determine the type of a variable and it will return a type of "undefined" for an Undefined variable.
 
For this example, the value NotThere has not been declared. (Note that it is optional to enclose the argument for the typeof operator inside a pair of parenthesis.)
 
Code:
document.write("NotThere is of type = " + typeof NotThere)

 
Output:
NotThere is of type = undefined
 
In this example, the value IsThere has been declared, but it is not assigned a value.
 
Code:
var IsThere;
document.write("IsThere is of type = " + typeof IsThere)

 
Output:
IsThere is of type = undefined
 
NOTE:
 
In Internet Explorer, if you attempt to utilize an undefined variable, you will get a runtime error message b


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information